import request from '@/utils/request'

//引入枚举
enum Api {
  // 获取spu列表 get /admin/product/{page}/{limit}
  getSpuList = '/admin/product',

  // 添加spu post /admin/product/saveSpuInfo 
  saveSpu = `/admin/product/saveSpuInfo`,

  // 更新spu post /admin/product/updateSpuInfo 
  updateSpu = `/admin/product/updateSpuInfo`,

  // 删除spu delete /admin/product/deleteSpu/{spuId} 
  deleteSpu = `/admin/product/deleteSpu`,

  // 获取品牌数据 get /admin/product/baseTrademark/getTrademarkList 
  getTrademarkAllList = '/admin/product/baseTrademark/getTrademarkList',

  // 获取属性列表 get /admin/product/baseSaleAttrList 
  getSaleAttrList = '/admin/product/baseSaleAttrList',

  // 获取基础销售属性列表 get /admin/product/spuSaleAttrList/{spuId} 
  getSpuSaleAttrList = '/admin/product/spuSaleAttrList',

  //  获取图片列表get /admin/product/spuImageList/{spuId} 
  getSpuImageList = '/admin/product/spuImageList'
}
// 1 获取spu列表
export const reqGetSpuListData = (page:number,limit:number,category3Id:number) => {
  return request.get(Api.getSpuList + `/${page}/${limit}?category3Id=${category3Id}`)
}

// 2 添加spu
export const reqPostSpuInfo = (spuInfo:any) => {
  return request.post(Api.saveSpu,spuInfo)
}

// 3 更新spu
export const updateSpuInfo = (spuInfo:any) => {
  return request.post(Api.updateSpu,spuInfo)
}
// 4删除spu
export const reqDeleteSpuInfo = (spuId:number) => {
  return request.delete(Api.deleteSpu+`/${spuId}`)
}

// 5 获取品牌数据
export const reqGetTrademarkAllList = () => {
  return request.get(Api.getTrademarkAllList)
}

// 6 获取属性列表
export const reqGetBaseSaleAttrList =() => {
  return request.get(Api.getSaleAttrList)
}

 // 7 获取基础销售属性列表
export const  reqGetSpuSaleAttrList = (spuId:number) => {
  return request.get(Api.getSpuSaleAttrList + `/${spuId}`)
}

// 8 获取图片列表get
export const reqGetSpuImageList = (spuId:number) => {
  return request.get(Api.getSpuImageList + `/${spuId}`)
}
